/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import flightlifter.Draw;
import flightlifter.FlightLifter;
import java.awt.event.MouseEvent;
import org.lwjgl.opengl.GL11;


public abstract class GUIComponent{

    protected GUI parent = null;

    GUIListener listener;

    int over = 0;
    protected int locX =0;
    protected int locY = 0;

    protected int cWidth = 50;
    protected int cHeight = 15;
    int hborder = 0, vborder = 0;

    public void setParent(GUI parent){
        this.parent = parent;

    }

    public void setPosition(int x, int y){
        locX = x;
        locY = y;
    }

    public void setSize(int width, int height){
        cWidth = width;
        cHeight = height;
    }

    public void draw(){
        
        if (over == 1){
            GL11.glColor4f(parent.HIGHLIGHT[0],parent.HIGHLIGHT[1],parent.HIGHLIGHT[2], parent.HIGHLIGHT[3]);
            Draw.fillRect(locX, locY, cWidth + 1, cHeight);
  
        }
        
        
    }

    public int mouseClicked(int mouseX, int mouseY){
        
        //check if mouse pressed on this object
        if (mouseX >= locX && mouseX <= locX + cWidth ){
            if (mouseY <= locY + cHeight && mouseY >= locY ){
                parent.focusedComp = this;
                return 1;

            }
        }
         
         return 0;


    }

    public int mousePressed(int mouseX,int mouseY){

        //check if mouse pressed on this object
        if (mouseX >= locX && mouseX <= locX + cWidth ){
            if (mouseY <= locY + cHeight && mouseY >= locY ){
                parent.focusedComp = this;
                return 1;
            }
        }
        
       
         return 0;

    }

    public int mouseMoved(int mouseX,int mouseY){
        
        //check if mouse over this object
        if (mouseX >= locX && mouseX <= locX + cWidth  && mouseY < locY + cHeight && mouseY >= locY ){
            over = 1;
            return 1;
        } else{
            over = 0;
            return 0;
        }
       
    }

    public void addGUIListener(GUIListener listener){
        this.listener = listener;
    }

    public void mouseDragged(int mouseDX,int mouseDY){
        locX += mouseDX;
        locY += mouseDY;
    };
}